home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / misc / emu / p-interp.lha / p-interp-0.4 / Printer.c < prev    next >
C/C++ Source or Header  |  2001-06-10  |  2KB  |  97 lines

  1. /*
  2.  
  3.   P-Code interpreter (to run the apple pascal system)
  4.   Copyright (C) 2000 Mario Klebsch
  5.  
  6.   This program is free software; you can redistribute it and/or modify
  7.   it under the terms of the GNU General Public License as published by
  8.   the Free Software Foundation; either version 2 of the License, or
  9.   (at your option) any later version.
  10.  
  11.   This program is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.   GNU General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU General Public License
  17.   along with this program; if not, write to the Free Software
  18.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20.   $Log: Printer.c,v $
  21.   Revision 1.2  2001/06/06 23:10:00  mario
  22.   Ausgabe wahlweise über das Spool-System oder direkt an ein Device.
  23.  
  24.   Revision 1.1  2001/05/20 20:14:40  mario
  25.   Neues Gerät PRINTER: implementiert
  26.  
  27.  
  28.  
  29. */
  30.  
  31. #ident "$Id: Printer.c,v 1.2 2001/06/06 23:10:00 mario Exp $";
  32.  
  33. #include <stdio.h>
  34.  
  35. #include "psystem.h"
  36. #include "Memory.h"
  37.  
  38. FILE *Printer=NULL;
  39.  
  40. void PrinterWrite(byte ch, word Mode)
  41. {
  42.   static int Dle=0;
  43.  
  44.   if (!Printer)
  45. #ifdef PRINT_DEVICE
  46.     Printer=fopen(PRINT_DEVICE, "w");
  47. #else
  48.     Printer=popen("lp -s", "w");
  49. #endif
  50.  
  51.   if (!Printer)
  52.     {
  53.     }
  54.   else
  55.     if (!Dle)
  56.       {
  57.     switch(ch)
  58.       {
  59.       case 0:
  60.         if (!(Mode&0x8))
  61.           return;
  62.       case 13:            /* carriage return            */
  63.         if (!(Mode&0x4))
  64.           ch='\n';
  65.         break;
  66.       case 16:            /* DLE prefix                */
  67.         if (!(Mode&0x8))
  68.           {
  69.         Dle=1;
  70.         return;
  71.           }
  72.         break;
  73.       }
  74.     fputc(ch, Printer);
  75.       }
  76.     else
  77.       {
  78.     ch -= 0x20;
  79.     while (ch--)
  80.       fputc(' ', Printer);
  81.     Dle=0;
  82.     }
  83. }
  84.  
  85. void PrinterClear(void)
  86. {
  87.   if (Printer)
  88.     {
  89. #ifdef PRINT_DEVICE
  90.       fclose(Printer);
  91. #else
  92.       pclose(Printer);
  93. #endif
  94.       Printer=NULL;
  95.     }
  96. }
  97.